#include <stdio.h>
#include <string.h>
#include <openssl/hmac.h>

int main(int argc, const char **argv) {
    char key[] = "rOrLmAHHvFy2kP3uSTE5GHnhyebwJ35s";
    char data[] = "eyJ1c2VybmFtZSI6InhjeSIsInBhc3N3b3JkIjoiMTIzIn0=";//"{\"username\":\"xcy\",\"password\":\"123\"}";

    unsigned char digest[EVP_MAX_MD_SIZE] {'\0'};
    unsigned int digest_len = 0;

    auto str = HMAC(EVP_sha1(), key, strlen(key), (unsigned char *)data, strlen(data), digest, &digest_len);
    printf("ret:%s, digest:%s len:%u\n", str, digest, digest_len);


    char mdstring[2 * digest_len + 1] {'\0'};
    for (int i = 0; i < digest_len; ++i)
        sprintf(mdstring + i * 2, "%02x", (unsigned int)digest[i]);


    printf("hmac digist:%s\n", mdstring);
    return 0;
}
